﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft Corp." file="GetHostedServicePropertiesCommand.cs">
//   All rights reserved. See License.txt in the project root for license information.
// </copyright>
// 
// --------------------------------------------------------------------------------------------------------------------
namespace AzureManagement.AzureCommands
{
    using RestClient;

    public class GetHostedServicePropertiesCommand : AzureManagementCommand
    {
        private const string EmbedDetailParameterName = "embed-detail";

        private readonly string serviceName;

        private readonly bool embedDetails;

        public GetHostedServicePropertiesCommand(
            IAzureServiceContext serviceContext, string serviceName, bool embedDetails = false)
            : base(serviceContext)
        {
            this.serviceName = serviceName;
            this.embedDetails = embedDetails;
        }

        protected override RequestContext GetRequestContext()
        {
            return this.CreateGetOperationRequestContext();
        }

        protected override string FormatPath(IAzureServiceContext azureServiceContext)
        {
            return string.Format(
                "{0}/services/hostedservices/{1}", azureServiceContext.SubscriptionId, this.serviceName);
        }

        protected override void AddParameters(RequestContext requestContext)
        {
            if (this.embedDetails)
            {
                requestContext.AddParameter(EmbedDetailParameterName, "true");
            }
        }
    }
}